package com.atguigu.gmall.controller;

import com.atguigu.gmall.bean.Person;
import com.atguigu.gmall.bean.UserAddress;
import com.atguigu.gmall.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class OrderController {

	@Autowired
	OrderService orderService;

	@ResponseBody
	@RequestMapping("/initOrder")
	public List<UserAddress> initOrder(@RequestParam("uid") String userId) {
		return orderService.initOrder(userId);
	}

	@GetMapping("/doOrder/{orderId}")
	@ResponseBody
	public List<Person> doOrder(@PathVariable("orderId") String orderId) {
		return orderService.doOrder(orderId);
	}

	@GetMapping("/async1")
	@ResponseBody
	public String async1(String name) throws Exception {
		return orderService.checkAsync(name);
	}
}
